From 4e3ffd4bf00ab71ef64c31a45d5c3e2838aa78ee Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 26 Oct 2016 16:47:20 +0200 Subject: Don't follow type aliases in getClassByName and friends This makes getClassByName fail / getClassIfDefined return NoSymbol when querying an alias. The current behavior can confuse the classfile parser: when parsing a class, a cross-check verifies that `pool.getClassSymbol(nameIdx)` returns the symbol of the class currently being parsed. If there's a type alias that shadows the linked class, following the alias would return an unrelated class. (The cross-check didn't fail because there are some other guards around it) The logic to follow aliases was was added in ff98878, without a clear explanation. Note that `requiredClass[C]` works if `C` is an alias, it is expanded by the compiler. --- src/reflect/scala/reflect/internal/Mirrors.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index 3d1c160d52..ff2bed8105 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -91,7 +91,6 @@ trait Mirrors extends api.Mirrors { private def ensureClassSymbol(fullname: String, sym: Symbol): ClassSymbol = { var result = sym - while (result.isAliasType) result = result.info.typeSymbol result match { case x: ClassSymbol => x case _ => MissingRequirementError.notFound("class " + fullname) -- cgit v1.2.3