summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala3
-rw-r--r--test/files/pos/bug4305.scala31
2 files changed, 33 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 8cc977fa65..fd86fb7345 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3396,7 +3396,8 @@ A type's typeSymbol should never be inspected directly.
else instParam(ps.tail, as.tail);
val symclazz = sym.owner
if (symclazz == clazz && !pre.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) {
- pre.baseType(symclazz) match {
+ // have to deconst because it may be a Class[T].
+ pre.baseType(symclazz).deconst match {
case TypeRef(_, basesym, baseargs) =>
//Console.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs+", pre = "+pre+", symclazz = "+symclazz);//DEBUG
if (sameLength(basesym.typeParams, baseargs)) {
diff --git a/test/files/pos/bug4305.scala b/test/files/pos/bug4305.scala
new file mode 100644
index 0000000000..ba3eb65bc1
--- /dev/null
+++ b/test/files/pos/bug4305.scala
@@ -0,0 +1,31 @@
+object T1 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ classOf[C].getTypeParameters
+ }
+ }
+}
+
+object T2 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ val x = classOf[C]
+ x.getTypeParameters
+ }
+ }
+}
+
+object T3 {
+ trait T[A]
+ class C extends T[String]
+ object Test {
+ def main(args: Array[String]): Unit = {
+ val x: Class[C] = classOf[C]
+ x.getTypeParameters
+ }
+ }
+} \ No newline at end of file