Inconsistency in Type Inference?

struct SomeStruct: RawRepresentable
{
    typealias RawValue = String
    var rawValue: String
    
    static let aValue = SomeStruct(rawValue: "One")
    static let anotherValue = SomeStruct(rawValue: "Two")
    
    struct SubStruct
    {
        static let yetAnotherValue = SomeStruct(rawValue: "Two")
    }
}

let a: SomeStruct = .aValue
let b: SomeStruct = .SubStruct.yetAnotherValue
let c: SomeStruct = SomeStruct.SubStruct.yetAnotherValue

a works but b doesn't. I feel that this is inconsistent. I thought that if the type is inferred, then '.' is the shorthand for 'Type.'. Is it not so?

That is currenlty the correct behaviour. How should the compiler know where to start the query?

Consider the a similar example of color types:

class NSColor {
  static let clear: NSColor { ... }
  var cgColor: CGColor { ... }
}
class UIColor {
  static let clear: UIColor { ... }
  var cgColor: CGColor { ... }
}

let color: CGColor = .clear.cgColor // This is ambiguous

In your example even if there is no second SubStruct nested anywhere the compiler does not know where to start querying to get the correct and expected result.

In case that I said something wrong, please feel free to correct me.

In this case colour's type is CGColor and .clear should be inferred as CGColor.clear which is ambiguous.

I this case b's type is SomeStruct and so .SubStruct.yetAnotherValue should be inferred as SomeStruct.SubStruct.yetAnotherValue which is what I want.

The complier just assumes '.' to mean 'TypeOfThisVariable.'

IIRC this topic was discussed quite a few times before. You may want to search the forums for it and open a new discussion thread on the evolution if you want to push it further. If you're going to tackle it please provide new information and summarize everything that has already been said and considered. Please also note that simply bumping old threads is discouraged. Site admins tend to close threads that are bumped.

Oh. I didn't know that. I tried looking for a discussion about before starting this thread and again now, but I wasn't able to find any. Can you point me towards a thread or search term which will help me find the thread?

Edit: Just found this

related: Referring to failable initializer with leading dot syntax