Closed fabianfett closed 4 years ago
Verified the issue with @weissi on vapor discord chat:
Yes That’s why in the sswg we try to make sure that module and type names never clash It’s unfortunate though :sob: Maybe you want to file a Swift bug, there might already be one but I don’t think so
Also this resolves name clashes with: https://github.com/LiveUI/S3
fixed in #225
Original title: Namespaces don't work if Facade struct has same name as Library
Origin of the issue: https://github.com/fabianfett/swift-lambda-runtime/pull/25
The code that breaks
LambdaRuntime
must be imported because of theEnvironment
type. SinceLambdaRuntime
also holds aDynamoDB
type, the compiler emits an error:There are two issues here:
LambdaRuntime Issue
Since the package
LambdaRuntime
has the same name as the classLambdaRuntime.DynamoDB
the compiler can not differentiate between the namespace and the class. Trying to access:LambdaRuntime.DynamoDB
leads to the following error:For that reason, I will rename
LambdaRuntime
the class toRuntime
. With thisLambdaRuntime
always refers to the package/namespace and not a struct. This is already in progress with:https://github.com/fabianfett/swift-lambda-runtime/pull/26
With this fix done, we can now access
LambdaRuntime.DynamoDB
without problems.AWSSDKSwift Issue
Even though we can specify
LambdaRuntime.DynamoDB
we still can not specifyDynamoDB.DynamoDB
since we still can't access the namespace. The whole Swift namespace is broken as long as a type has the same name as the library. IMHO we should start a rename here to prevent those naming collisions where one can not fallback on the namespaces. I know this is breaking. But it's also a great feature to not fall apart in the moment of naming collisions.For easy reproduction this is the
Package.swift
I used.This issue went undiscovered since I haven't used both frameworks in a single file yet.