summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/nsc/symtab
diff options
context:
space:
mode:
Diffstat (limited to 'test/junit/scala/tools/nsc/symtab')
-rw-r--r--test/junit/scala/tools/nsc/symtab/FlagsTest.scala53
-rw-r--r--test/junit/scala/tools/nsc/symtab/StdNamesTest.scala7
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala33
3 files changed, 58 insertions, 35 deletions
diff --git a/test/junit/scala/tools/nsc/symtab/FlagsTest.scala b/test/junit/scala/tools/nsc/symtab/FlagsTest.scala
index fc0e8b0f6b..4e78ca7f22 100644
--- a/test/junit/scala/tools/nsc/symtab/FlagsTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/FlagsTest.scala
@@ -2,15 +2,17 @@ package scala.tools.nsc
package symtab
import org.junit.Assert._
-import scala.tools.testing.AssertUtil._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import scala.tools.testing.BytecodeTesting
+
@RunWith(classOf[JUnit4])
-class FlagsTest {
+class FlagsTest extends BytecodeTesting {
object symbolTable extends SymbolTableForUnitTesting
import symbolTable._
+
import Flags._
def sym = NoSymbol.newTermSymbol(nme.EMPTY)
@@ -31,13 +33,7 @@ class FlagsTest {
@Test
def testTimedFlags(): Unit = {
- testLate(lateDEFERRED, _.isDeferred)
- testLate(lateFINAL, _.isFinal)
- testLate(lateINTERFACE, _.isInterface)
- testLate(lateMETHOD, _.isMethod)
- testLate(lateMODULE, _.isModule)
testNot(PROTECTED | notPROTECTED, _.isProtected)
- testNot(OVERRIDE | notOVERRIDE, _.isOverride)
testNot(PRIVATE | notPRIVATE, _.isPrivate)
assertFalse(withFlagMask(AllFlags)(sym.setFlag(PRIVATE | notPRIVATE).isPrivate))
@@ -86,4 +82,45 @@ class FlagsTest {
assertEquals(withFlagMask(AllFlags)(sym.setFlag(lateFlags).flags), lateFlags | lateable)
}
+
+ @Test
+ def javaClassMirrorAnnotationFlag(): Unit = {
+ import scala.reflect.runtime.universe._
+ val dep = typeOf[java.lang.Deprecated].typeSymbol
+ assertTrue(dep.isJavaAnnotation && dep.isJava)
+ }
+
+ @Test
+ def interfaceFlag(): Unit = {
+ // scala traits are `isInterface` if they have only type defs and abstract methods / fields.
+ // java interfaces are always `isInterface`.
+ val scalaCode =
+ """package p
+ |trait T1 {
+ | import scala.collection
+ | def m: Int
+ | val f: Int
+ | type T <: AnyRef
+ |}
+ |trait T2 {
+ | def m = 1
+ |}
+ |trait T3 {
+ | val f = 1
+ |}
+ |trait T4 {
+ | println()
+ |}
+ """.stripMargin
+ val javaI1 = "package p; interface I1 { int m(); }"
+ val javaI2 = "package p; interface I2 { default int m() { return 1; } }"
+ compiler.compileClasses(code = scalaCode, javaCode = (javaI1, "I1.java") :: (javaI2, "I2.java") :: Nil)
+ import compiler.global.rootMirror._
+ assert( getRequiredClass("p.T1").isInterface)
+ assert(!getRequiredClass("p.T2").isInterface)
+ assert(!getRequiredClass("p.T3").isInterface)
+ assert(!getRequiredClass("p.T4").isInterface)
+ assert( getRequiredClass("p.I1").isInterface)
+ assert( getRequiredClass("p.I2").isInterface)
+ }
}
diff --git a/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala b/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala
index 91f94e09b6..5949008d8a 100644
--- a/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala
@@ -2,16 +2,17 @@ package scala.tools.nsc
package symtab
import org.junit.Assert._
-import scala.tools.testing.AssertUtil._
-import org.junit.{Ignore, Test}
+import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import scala.tools.testing.AssertUtil._
+
@RunWith(classOf[JUnit4])
class StdNamesTest {
object symbolTable extends SymbolTableForUnitTesting
import symbolTable._
- import nme.{SPECIALIZED_SUFFIX, unspecializedName, splitSpecializedName}
+ import nme.{SPECIALIZED_SUFFIX, splitSpecializedName, unspecializedName}
@Test
def testNewTermNameInvalid(): Unit = {
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
index f0f20acf07..fb05ab8d5a 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
@@ -2,10 +2,7 @@ package scala.tools.nsc
package symtab
import scala.reflect.ClassTag
-import scala.reflect.internal.{Phase, NoPhase, SomePhase}
-import scala.tools.nsc.classpath.FlatClassPath
-import scala.tools.nsc.settings.ClassPathRepresentationType
-import scala.tools.util.FlatClassPathResolver
+import scala.reflect.internal.{NoPhase, Phase, SomePhase}
import scala.tools.util.PathResolver
import util.ClassPath
import io.AbstractFile
@@ -30,8 +27,7 @@ class SymbolTableForUnitTesting extends SymbolTable {
override def isCompilerUniverse: Boolean = true
- def classPath = platform.classPath
- def flatClassPath: FlatClassPath = platform.flatClassPath
+ def classPath: ClassPath = platform.classPath
object platform extends backend.Platform {
val symbolTable: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this
@@ -39,22 +35,12 @@ class SymbolTableForUnitTesting extends SymbolTable {
def platformPhases: List[SubComponent] = Nil
- lazy val classPath: ClassPath[AbstractFile] = {
- assert(settings.YclasspathImpl.value == ClassPathRepresentationType.Recursive,
- "It's not possible to use the recursive classpath representation, when it's not the chosen classpath scanning method")
- new PathResolver(settings).result
- }
-
- private[nsc] lazy val flatClassPath: FlatClassPath = {
- assert(settings.YclasspathImpl.value == ClassPathRepresentationType.Flat,
- "It's not possible to use the flat classpath representation, when it's not the chosen classpath scanning method")
- new FlatClassPathResolver(settings).result
- }
+ private[nsc] lazy val classPath: ClassPath = new PathResolver(settings).result
def isMaybeBoxed(sym: Symbol): Boolean = ???
def needCompile(bin: AbstractFile, src: AbstractFile): Boolean = ???
def externalEquals: Symbol = ???
- def updateClassPath(subst: Map[ClassPath[AbstractFile], ClassPath[AbstractFile]]): Unit = ???
+ def updateClassPath(subst: Map[ClassPath, ClassPath]): Unit = ???
}
object loaders extends symtab.SymbolLoaders {
@@ -69,10 +55,7 @@ class SymbolTableForUnitTesting extends SymbolTable {
class GlobalMirror extends Roots(NoSymbol) {
val universe: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this
- def rootLoader: LazyType = settings.YclasspathImpl.value match {
- case ClassPathRepresentationType.Flat => new loaders.PackageLoaderUsingFlatClassPath(FlatClassPath.RootPackage, flatClassPath)
- case ClassPathRepresentationType.Recursive => new loaders.PackageLoader(classPath)
- }
+ def rootLoader: LazyType = new loaders.PackageLoader(ClassPath.RootPackage, classPath)
override def toString = "compiler mirror"
}
@@ -102,7 +85,7 @@ class SymbolTableForUnitTesting extends SymbolTable {
// minimal Run to get Reporting wired
def currentRun = new RunReporting {}
class PerRunReporting extends PerRunReportingBase {
- def deprecationWarning(pos: Position, msg: String): Unit = reporter.warning(pos, msg)
+ def deprecationWarning(pos: Position, msg: String, since: String): Unit = reporter.warning(pos, msg)
}
protected def PerRunReporting = new PerRunReporting
@@ -119,7 +102,9 @@ class SymbolTableForUnitTesting extends SymbolTable {
}
phasesArray
}
- lazy val treeInfo: scala.reflect.internal.TreeInfo{val global: SymbolTableForUnitTesting.this.type} = ???
+ lazy val treeInfo = new scala.reflect.internal.TreeInfo {
+ val global: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this
+ }
val currentFreshNameCreator = new reflect.internal.util.FreshNameCreator