Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
Code clean up
  • Loading branch information
aukgit committed Apr 16, 2020
1 parent 711f051 commit 0521495
Showing 1 changed file with 0 additions and 77 deletions.
77 changes: 0 additions & 77 deletions src/main/scala/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,9 @@ import slick.jdbc.SQLiteProfile.api._
import slick.sql.FixedSqlAction
import scala.reflect.runtime.universe

case class Case(foo: Int) {
val w = foo
val w2 = "Hello"
println("Case Case Instantiated")
}

class Class {
val w2 = "HellWo"
println("Class Instantiated")
}

object Inst {

def apply(className: String, arg: Any) = {
val runtimeMirror: universe.Mirror =
universe.runtimeMirror(getClass.getClassLoader)

val classSymbol: universe.ClassSymbol =
runtimeMirror.classSymbol(Class.forName(className))

val classMirror: universe.ClassMirror =
runtimeMirror.reflectClass(classSymbol)

if (classSymbol.companion.toString == "<none>") // TODO: use nicer method "hiding" in the api?
{
println(s"Info: $className has no companion object")
val constructors =
classSymbol.typeSignature.members.filter(_.isConstructor).toList
if (constructors.length > 1) {
println(s"Info: $className has several constructors")
} else {
val constructorMirror = classMirror.reflectConstructor(
constructors.head.asMethod) // we can reuse it
constructorMirror()
}

} else {
val companionSymbol = classSymbol.companion
println(s"Info: $className has companion object $companionSymbol")
// TBD
}

}
}

object app extends App {
val c = Inst("Class", "")
val cc = Inst("Case", "")
val appManager = Inst("AppManager", "")
println(c)
}

class Sample[T] {
type T

def getString[T, T2](a : T, b : T2) : String = a.toString + s"\n${b.toString}"
}


object Application {
def main(args: Array[String]): Unit = {
val appManager = new AppManager

// AppLogger.info("Help", 3, false)

class Obj { private def foo(x: Int, y: String): Long = x + y.length }
import scala.reflect.runtime.{universe => ru}
def getTypeTag[T: ru.TypeTag](obj: T) = {
ru.typeTag[T]
}


val x = getTypeTag(appManager)
val y = new Sample[AppManager]
val y2 = y.getString(appManager, this)
val m1 = getTypeTag(y)

println(m1.tpe)

println(x)
println(x.tpe)
}
}

0 comments on commit 0521495

Please sign in to comment.