Skip to content

Commit 6e223af

Browse files
committed
WIP: Also mark free global classes
1. Add capture sets also for self types of global classes 2. Also mark free capabilities in global classes
1 parent a909249 commit 6e223af

File tree

5 files changed

+13
-459
lines changed

5 files changed

+13
-459
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ class CheckCaptures extends Recheck, SymTransformer:
589589
tree.srcPos)
590590

591591
def recur(cs: CaptureSet, env: Env, lastEnv: Env | Null): Unit =
592-
if env.kind != EnvKind.Boxed && !env.owner.isStaticOwner && !cs.isAlwaysEmpty then
592+
if env.kind != EnvKind.Boxed && !cs.isAlwaysEmpty then
593593
// Only captured references that are visible from the environment
594594
// should be included.
595595
val included = cs.filter: c =>

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,10 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
723723
val cinfo @ ClassInfo(prefix, _, ps, decls, selfInfo) = cls.classInfo
724724

725725
// Compute new self type
726-
def isInnerModule = cls.is(ModuleClass) && !cls.isStatic
727726
val selfInfo1 =
728-
if (selfInfo ne NoType) && !isInnerModule then
727+
if (selfInfo ne NoType) && !cls.is(ModuleClass) then
729728
// if selfInfo is explicitly given then use that one, except if
730-
// self info applies to non-static modules, these still need to be inferred
729+
// self info applies to a module class, these still need to be inferred
731730
selfInfo
732731
else if cls.isPureClass then
733732
// is cls is known to be pure, nothing needs to be added to self type

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,15 @@ abstract class Recheck extends Phase, SymTransformer:
242242
if name.is(OuterSelectName) then tree.tpe
243243
else
244244
val pre = ta.maybeSkolemizePrefix(qualType, name)
245+
val treeSym = tree.symbol.orElse:
246+
tree.tpe match
247+
case TermRef(_, desig: Symbol) => desig
248+
case _ => NoSymbol
245249
val mbr =
246250
sharpen(
247251
qualType.findMember(name, pre,
248252
excluded = if tree.symbol.is(Private) then EmptyFlags else Private
249-
)).suchThat(tree.symbol == _)
253+
)).suchThat(_ == treeSym)
250254
val newType = tree.tpe match
251255
case prevType: NamedType =>
252256
val prevDenot = prevType.denot
@@ -381,6 +385,9 @@ abstract class Recheck extends Phase, SymTransformer:
381385
assert(fntpe.paramInfos.hasSameLengthAs(tree.args))
382386
val argTypes = tree.args.map(recheck(_))
383387
constFold(tree, fntpe.instantiate(argTypes))
388+
case NoType =>
389+
println(i"MISSING TYPE FOR $tree")
390+
tree.tpe
384391

385392
def recheckTyped(tree: Typed)(using Context): Type =
386393
val tptType = recheck(tree.tpt)

library/src/scala/collection/StringOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object StringOps {
160160
}
161161

162162
/** Avoid an allocation in [[collect]]. */
163-
private val fallback: Any => Any = _ => fallback
163+
private val fallback: Any -> Any = _ => fallback
164164
}
165165

166166
/** Provides extension methods for strings.

0 commit comments

Comments
 (0)