diff options
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Kinds.scala | 3 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Trees.scala | 15 | ||||
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 11 |
3 files changed, 24 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index 08686832ef..3ab7b20ecd 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -184,6 +184,7 @@ trait Kinds { ) } else { + hkarg.initialize // SI-7902 otherwise hkarg.typeParams yields List(NoSymbol)! debuglog("checkKindBoundsHK recursing to compare params of "+ hkparam +" with "+ hkarg) kindErrors ++= checkKindBoundsHK( hkarg.typeParams, @@ -229,4 +230,4 @@ trait Kinds { } } } -}
\ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 53b9b1d88e..0e5985face 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1538,6 +1538,21 @@ trait Trees extends api.Trees { self: SymbolTable => def duplicateAndKeepPositions(tree: Tree) = new Duplicator(focusPositions = false) transform tree + def wrapIntoTerm(tree: Tree): Tree = { + if (!tree.isTerm) Block(List(tree), Literal(Constant(()))) else tree + } + + // this is necessary to avoid crashes like https://github.com/scalamacros/paradise/issues/1 + // when someone tries to c.typecheck a naked MemberDef + def wrappingIntoTerm(tree0: Tree)(op: Tree => Tree): Tree = { + val neededWrapping = !tree0.isTerm + val tree1 = wrapIntoTerm(tree0) + op(tree1) match { + case Block(tree2 :: Nil, Literal(Constant(()))) if neededWrapping => tree2 + case tree2 => tree2 + } + } + // ------ copiers ------------------------------------------- def copyDefDef(tree: Tree)( diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 6fdb238462..9c0781ca06 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -685,8 +685,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni module.moduleClass setInfo new ClassInfoType(List(), newScope, module.moduleClass) } - def enter(sym: Symbol, mods: Int) = - (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym + def enter(sym: Symbol, mods: Int) = followStatic(clazz, module, mods).info.decls enter sym def enterEmptyCtorIfNecessary(): Unit = { if (jclazz.getConstructors.isEmpty) @@ -733,8 +732,12 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * If Java modifiers `mods` contain STATIC, return the module class * of the companion module of `clazz`, otherwise the class `clazz` itself. */ - private def followStatic(clazz: Symbol, mods: Int) = - if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz + private def followStatic(clazz: Symbol, mods: Int): Symbol = followStatic(clazz, clazz.companionModule, mods) + + private def followStatic(clazz: Symbol, module: Symbol, mods: Int): Symbol = + // SI-8196 `orElse(clazz)` needed for implementation details of the backend, such as the static + // field containing the cache for structural calls. + if (jModifier.isStatic(mods)) module.moduleClass.orElse(clazz) else clazz /** Methods which need to be treated with care * because they either are getSimpleName or call getSimpleName: |