@@ -220,7 +220,7 @@ object Namer extends Phase[Parsed, NameResolved] {
220220 ExternInterface (Context .nameFor(id), tps, decl)
221221 })
222222
223- case d @ source.ExternDef (id, tparams, vparams, bparams, captures, ret, bodies, doc, span) => {
223+ case d @ source.ExternDef (id, tparams, vparams, bparams, captures, ret, bodies, doc, span) =>
224224 val name = Context .nameFor(id)
225225 val capt = resolve(captures)
226226 Context .define(id, Context scoped {
@@ -235,7 +235,6 @@ object Namer extends Phase[Parsed, NameResolved] {
235235
236236 ExternFunction (name, tps.unspan, vps.unspan, bps.unspan, tpe, eff, capt, bodies, d)
237237 })
238- }
239238
240239 case d @ source.ExternResource (id, tpe, doc, span) =>
241240 val name = Context .nameFor(id)
@@ -348,14 +347,14 @@ object Namer extends Phase[Parsed, NameResolved] {
348347 }
349348 }
350349
351- case source.InterfaceDef (id , tparams, operations, doc, span) =>
350+ case source.InterfaceDef (interfaceId , tparams, operations, doc, span) =>
352351 // symbol has already been introduced by the previous traversal
353- val interface = Context .symbolOf(id ).asInterface
352+ val interface = Context .symbolOf(interfaceId ).asInterface
354353 interface.operations = operations.map {
355354 case op @ source.Operation (id, tparams, vparams, bparams, ret, doc, span) => Context .at(op) {
356355 val name = Context .nameFor(id)
357356
358- Context .scopedWithName(id.name) {
357+ val opSym = Context .scopedWithName(id.name) {
359358 // the parameters of the interface are in scope
360359 interface.tparams.foreach { p => Context .bind(p) }
361360
@@ -372,10 +371,16 @@ object Namer extends Phase[Parsed, NameResolved] {
372371 // 2) the annotated type parameters on the concrete operation
373372 val (result, effects) = resolve(ret)
374373
375- val opSym = Operation (name, interface.tparams ++ tps.unspan, resVparams, resBparams, result, effects, interface, op)
374+ Operation (name, interface.tparams ++ tps.unspan, resVparams, resBparams, result, effects, interface, op)
375+ }
376+
377+ // define in namespace ...
378+ Context .namespace(interfaceId.name) {
376379 Context .define(id, opSym)
377- opSym
378380 }
381+ // ... and bind outside
382+ Context .bind(opSym)
383+ opSym
379384 }
380385 }
381386
@@ -385,19 +390,26 @@ object Namer extends Phase[Parsed, NameResolved] {
385390 }
386391
387392 // The type itself has already been resolved, now resolve constructors
388- case d @ source.DataDef (id , tparams, ctors, doc, span) =>
393+ case d @ source.DataDef (typeId , tparams, ctors, doc, span) =>
389394 val data = d.symbol
390- data. constructors = ctors map {
395+ val constructors = ctors map {
391396 case c @ source.Constructor (id, tparams, ps, doc, span) =>
392397 val constructor = Context scoped {
393398 val name = Context .nameFor(id)
394399 val tps = tparams map resolve
395400 Constructor (name, data.tparams ++ tps.unspan, Nil , data, c)
396401 }
397- Context .define(id, constructor)
402+ // DataType::Constructor()
403+ Context .namespace(typeId.name) {
404+ Context .define(id, constructor)
405+ }
398406 constructor.fields = resolveFields(ps.unspan, constructor, false )
399407 constructor
400408 }
409+ // export DataType::{Constructor1, ...}
410+ constructors.foreach { c => Context .bind(c) }
411+
412+ data.constructors = constructors
401413
402414 // The record has been resolved as part of the preresolution step
403415 case d @ source.RecordDef (id, tparams, fs, doc, span) =>
@@ -526,8 +538,8 @@ object Namer extends Phase[Parsed, NameResolved] {
526538 vargs foreach resolve
527539 bargs foreach resolve
528540
529- case source.Do (effect, target, targs, vargs, bargs, _) =>
530- Context .resolveEffectCall(effect map resolveBlockRef, target)
541+ case source.Do (target, targs, vargs, bargs, _) =>
542+ Context .resolveEffectCall(target)
531543 targs foreach resolveValueType
532544 vargs foreach resolve
533545 bargs foreach resolve
@@ -1136,15 +1148,9 @@ trait NamerOps extends ContextOps { Context: Context =>
11361148 /**
11371149 * Resolves a potentially overloaded call to an effect
11381150 */
1139- private [namer] def resolveEffectCall (eff : Option [InterfaceType ], id : IdRef ): Unit = at(id) {
1140-
1141- val syms = eff match {
1142- case Some (tpe) =>
1143- val interface = tpe.typeConstructor.asInterface
1144- val operations = interface.operations.filter { op => op.name.name == id.name }
1145- if (operations.isEmpty) Nil else List (operations.toSet)
1146- case None => scope.lookupOperation(id.path, id.name)
1147- }
1151+ private [namer] def resolveEffectCall (id : IdRef ): Unit = at(id) {
1152+
1153+ val syms = scope.lookupOperation(id.path, id.name)
11481154
11491155 if (syms.isEmpty) {
11501156 abort(pretty " Cannot resolve effect operation ${id}" )
0 commit comments