Skip to content

Commit

Permalink
Merge pull request #1565 from hylo-lang/synthetic-none-equal
Browse files Browse the repository at this point in the history
Remove needless custom implementation of `None.infix==`
  • Loading branch information
kyouko-taiga authored Aug 22, 2024
2 parents 0392eff + 9fdd999 commit e47c274
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4434,9 +4434,16 @@ struct TypeChecker {
// `X` from the resolution of the qualification and `Y` from the resolution of the candidate.
entityType = specialize(entityType, for: specialization, in: scopeOfUse)

// If `d` is a trait requirement, we have to remember the generic arguments that are part of
// its qualification in case its implementation is synthesized. Otherwise, we should only
// remember arguments to parameters that are in `d`'s scope.
var capturedArguments = GenericArguments.empty
for p in capturedGenericParameter(of: d) {
capturedArguments[p] = specialization[p]
if program.isRequirement(d) {
capturedArguments = specialization
} else {
for p in capturedGenericParameter(of: d) {
capturedArguments[p] = specialization[p]
}
}

return (entityType, capturedArguments, isConstructor)
Expand Down
5 changes: 0 additions & 5 deletions StandardLibrary/Sources/Core/Optional.hylo
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ public type None<T>: Regular {
/// Creates a value denoting the absence of an instance of `T`.
public memberwise init

// TODO: Remove when #1078 is implemented.
public fun infix==(_ other: Self) -> Bool {
true
}

}

public extension Optional {
Expand Down
2 changes: 2 additions & 0 deletions Tests/LibraryTests/TestCases/OptionalTests.hylo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//- compileAndRun expecting: .success

public fun main() {
precondition(None<Int>() == None<Int>())

var x = 42 as Optional<Int>
let y = if let i: Int = x { i.copy() } else { 0 }
precondition(y == 42)
Expand Down

0 comments on commit e47c274

Please sign in to comment.