File tree 1 file changed +9
-5
lines changed
compiler/src/dotty/tools/dotc/ast 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1153,17 +1153,21 @@ object desugar {
1153
1153
* - all pattern, value and method definitions
1154
1154
* - non-class type definitions
1155
1155
* - implicit classes and objects
1156
- * - companion objects of opaque types
1156
+ * - "companion objects" of wrapped type definitions
1157
+ * (i.e. objects having the same name as a wrapped type)
1157
1158
*/
1158
1159
def packageDef (pdef : PackageDef )(implicit ctx : Context ): PackageDef = {
1159
- val opaqueNames = pdef.stats.collect {
1160
- case stat : TypeDef if stat.mods.is(Opaque ) => stat.name
1160
+ def isWrappedType (stat : TypeDef ): Boolean =
1161
+ ! stat.isClassDef || stat.mods.isOneOf(DelegateOrImplicit )
1162
+ val wrappedTypeNames = pdef.stats.collect {
1163
+ case stat : TypeDef if isWrappedType(stat) => stat.name
1161
1164
}
1162
1165
def needsObject (stat : Tree ) = stat match {
1163
1166
case _ : ValDef | _ : PatDef | _ : DefDef | _ : Export => true
1164
1167
case stat : ModuleDef =>
1165
- stat.mods.isOneOf(DelegateOrImplicit ) || opaqueNames.contains(stat.name.stripModuleClassSuffix.toTypeName)
1166
- case stat : TypeDef => ! stat.isClassDef || stat.mods.isOneOf(DelegateOrImplicit )
1168
+ stat.mods.isOneOf(DelegateOrImplicit ) ||
1169
+ wrappedTypeNames.contains(stat.name.stripModuleClassSuffix.toTypeName)
1170
+ case stat : TypeDef => isWrappedType(stat)
1167
1171
case _ => false
1168
1172
}
1169
1173
val (nestedStats, topStats) = pdef.stats.partition(needsObject)
You can’t perform that action at this time.
0 commit comments