`import actor MyLib.MyActor` fails

With enums, structs, classes, protocols, and typealiases, you can explicitly import a type like so:

import enum MyLib.MyEnum
import struct MyLib.MyStruct
import class MyLib.MyClass
import protocol MyLib.MyProtocol
import typealias MyLib.MyTypealias

however this does not work for actors:

import actor MyLib.MyActor
// 3 compiler errors arise:
// 1. Consecutive statements on a line must be separated by ';'
// 2.Expressions are not allowed at the top level
// 3. No such module 'actor'

Is this just an oversight? Is it fine to import as a class?

this seems like it's probably an oversight, but it appears using the class syntax with an actor symbol works. i would suggest filing a bug if you have the time.

1 Like