Skip to content

Commit 3c1ff9a

Browse files
authored
Merge pull request #197 from scala/backport-lts-3.3-22356
Backport "Only check logicalOwners for methods, and not for classes, when looking for proxies" to 3.3 LTS
2 parents 1428f0f + 2881275 commit 3c1ff9a

File tree

16 files changed

+33
-301
lines changed

16 files changed

+33
-301
lines changed

compiler/src/dotty/tools/dotc/core/TypeUtils.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ class TypeUtils:
127127
case mt: MethodType => mt.isImplicitMethod || mt.resType.takesImplicitParams
128128
case _ => false
129129

130+
/** Is this a type deriving only from transparent classes?
131+
* @param traitOnly if true, all class symbols must be transparent traits
132+
*/
133+
def isTransparent(traitOnly: Boolean = false)(using Context): Boolean = self match
134+
case AndType(tp1, tp2) =>
135+
tp1.isTransparent(traitOnly) && tp2.isTransparent(traitOnly)
136+
case _ =>
137+
val cls = self.underlyingClassRef(refinementOK = false).typeSymbol
138+
cls.isTransparentClass && (!traitOnly || cls.is(Trait))
139+
130140
/** The constructors of this type that are applicable to `argTypes`, without needing
131141
* an implicit conversion. Curried constructors are always excluded.
132142
* @param adaptVarargs if true, allow a constructor with just a varargs argument to

compiler/src/dotty/tools/dotc/transform/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co
2929
def tracked: Iterable[Symbol] = free.keys
3030

3131
/** The outermost class that captures all free variables of a function
32-
* that are captured by enclosinh classes (this means that the function could
32+
* that are captured by enclosing classes (this means that the function could
3333
* be placed in that class without having to add more environment parameters)
3434
*/
3535
def logicalOwner: collection.Map[Symbol, Symbol] = logicOwner

compiler/src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ object LambdaLift:
127127

128128
private def proxy(sym: Symbol)(using Context): Symbol = {
129129
def liftedEnclosure(sym: Symbol) =
130-
deps.logicalOwner.getOrElse(sym, sym.enclosure)
130+
if sym.is(Method)
131+
then deps.logicalOwner.getOrElse(sym, sym.enclosure)
132+
else sym.enclosure
131133
def searchIn(enclosure: Symbol): Symbol = {
132134
if (!enclosure.exists) {
133135
def enclosures(encl: Symbol): List[Symbol] =

compiler/test/dotc/neg-best-effort-pickling.excludelist

Lines changed: 0 additions & 23 deletions
This file was deleted.

compiler/test/dotc/neg-best-effort-unpickling.excludelist

Lines changed: 0 additions & 17 deletions
This file was deleted.

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 0 additions & 120 deletions
This file was deleted.

compiler/test/dotc/pos-test-pickling.excludelist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,6 @@ hylolib
141141

142142
# typecheckErrors method unpickling
143143
i21415.scala
144+
145+
# LTS specific
146+
i21390.TrieMap.scala

compiler/test/dotc/run-test-pickling.blacklist

Lines changed: 0 additions & 52 deletions
This file was deleted.

presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ object HoverProvider:
107107
case (symbol, tpe, _) :: _
108108
if symbol.name == nme.selectDynamic || symbol.name == nme.applyDynamic =>
109109
fallbackToDynamics(path, printer, contentType)
110-
case symbolTpes @ ((symbol, tpe, None) :: _) =>
110+
case symbolTpes @ ((symbol, tpe, _) :: _) =>
111111
val exprTpw = tpe.widenTermRefExpr.deepDealias
112112
val hoverString =
113113
tpw match
@@ -153,21 +153,6 @@ object HoverProvider:
153153
case _ =>
154154
ju.Optional.empty().nn
155155
end match
156-
case (_, tpe, Some(namedTupleArg)) :: _ =>
157-
val exprTpw = tpe.widenTermRefExpr.deepDealias
158-
printer.expressionType(exprTpw) match
159-
case Some(tpe) =>
160-
ju.Optional.of(
161-
new ScalaHover(
162-
expressionType = Some(tpe),
163-
symbolSignature = Some(s"$namedTupleArg: $tpe"),
164-
docstring = None,
165-
forceExpressionType = false,
166-
contextInfo = printer.getUsedRenamesInfo,
167-
contentType = contentType
168-
)
169-
).nn
170-
case _ => ju.Optional.empty().nn
171156
end match
172157
end if
173158
end hover
@@ -183,7 +168,7 @@ object HoverProvider:
183168
case SelectDynamicExtractor(sel, n, name, rest) =>
184169
def findRefinement(tp: Type): Option[HoverSignature] =
185170
tp match
186-
case RefinedType(_, refName, tpe) if (name == refName.toString() || refName.toString() == nme.Fields.toString()) =>
171+
case RefinedType(_, refName, tpe) if name == refName.toString() =>
187172
val resultType =
188173
rest match
189174
case Select(_, asInstanceOf) :: TypeApply(_, List(tpe)) :: _ if asInstanceOf == nme.asInstanceOfPM =>
@@ -196,8 +181,7 @@ object HoverProvider:
196181
else printer.tpe(resultType)
197182

198183
val valOrDef =
199-
if refName.toString() == nme.Fields.toString() then ""
200-
else if n == nme.selectDynamic && !tpe.isInstanceOf[ExprType]
184+
if n == nme.selectDynamic && !tpe.isInstanceOf[ExprType]
201185
then "val "
202186
else "def "
203187

presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,6 @@ object MetalsInteractive:
203203
case _ =>
204204
Nil
205205

206-
// Handle select on named tuples
207-
case (Apply(Apply(TypeApply(fun, List(t1, t2)), List(ddef)), List(Literal(Constant(i: Int))))) :: _
208-
if fun.symbol.exists && fun.symbol.name == nme.apply &&
209-
fun.symbol.owner.exists && fun.symbol.owner == getModuleIfDefined("scala.NamedTuple").moduleClass =>
210-
def getIndex(t: Tree): Option[Type] =
211-
t.tpe.dealias match
212-
case AppliedType(_, args) => args.get(i)
213-
case _ => None
214-
val name = getIndex(t1) match
215-
case Some(c: ConstantType) => c.value.stringValue
216-
case _ => ""
217-
val tpe = getIndex(t2).getOrElse(NoType)
218-
List((ddef.symbol, tpe, Some(name)))
219-
220206
case path @ head :: tail =>
221207
if head.symbol.is(Exported) then
222208
val sym = head.symbol.sourceSymbol

0 commit comments

Comments
 (0)