From 990700039a5972a697471b460c021c5a2d6dbd65 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 20 Sep 2012 10:59:00 +0200 Subject: don't try to create tags w/o scala-reflect.jar Since recently type tags have relocated to scala-reflect.jar, meaning that they are no longer always on library classpath. In the compiler we do have code that generates type tags, and this code is bound to fail if scala-reflect.jar isn't there. I though this wouldn't be a problem, because type tag materialization is only going to be triggered by users explicitly requesting a type tag. That's generally true, but I overlooked a corner case. Since we provide manifest <-> type tag compatibility, manifest lookup can sometimes trigger tag lookup, which might result in tag synthesis, which blows up like this: http://groups.google.com/group/scala-internals/browse_thread/thread/166ce4b71b7c46bb This commit also ensures that type tag generation/interop doesnt sneak into the code of the libraries that don't have scala-reflect.jar on their classpath. For details refer to the discussion at scala-internals: http://groups.google.com/group/scala-internals/browse_thread/thread/72f6ce3010f4d8 --- src/compiler/scala/tools/nsc/typechecker/Tags.scala | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala index 0dbeafadbe..d82fbd7c77 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala @@ -59,11 +59,14 @@ trait Tags { * EmptyTree if `concrete` is true and the result contains unresolved (i.e. not spliced) type parameters and abstract type members. * EmptyTree if `allowMaterialization` is false, and there is no array tag in scope. */ - def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = { - val tagSym = if (concrete) TypeTagClass else WeakTypeTagClass - val tagTp = if (pre == NoType) TypeRef(ApiUniverseClass.toTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) - val taggedTp = appliedType(tagTp, List(tp)) - resolveTag(pos, taggedTp, allowMaterialization) - } + def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = + // if someone requests a type tag, but scala-reflect.jar isn't on the library classpath, then bail + if (pre == NoType && ApiUniverseClass == NoSymbol) EmptyTree + else { + val tagSym = if (concrete) TypeTagClass else WeakTypeTagClass + val tagTp = if (pre == NoType) TypeRef(ApiUniverseClass.toTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) + val taggedTp = appliedType(tagTp, List(tp)) + resolveTag(pos, taggedTp, allowMaterialization) + } } } \ No newline at end of file -- cgit v1.2.3