diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-19 18:12:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-19 18:12:17 +0000 |
commit | 4b0531b55a8d4971b7e297413e514072a99385e7 (patch) | |
tree | e25ad72c4d7b7f06b55be1ab8487ebda27ab2c41 | |
parent | 4380911a32eb7fa99faf5fea4ba5f9ad6a3a5258 (diff) | |
download | scala-4b0531b55a8d4971b7e297413e514072a99385e7.tar.gz scala-4b0531b55a8d4971b7e297413e514072a99385e7.tar.bz2 scala-4b0531b55a8d4971b7e297413e514072a99385e7.zip |
Fix for crasher with Class objects.
extempore. References #4305, no review.
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 3 | ||||
-rw-r--r-- | test/files/pos/bug4305.scala | 31 |
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 |